package com.haiertvbic.tvnow.pop;

import java.util.ArrayList;

import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.haiertvbic.tvnow.R;
import com.haiertvbic.tvnow.adapter.ActotDetailAdapter;

public class ActorResumePop extends PopWindow {
	private Activity context;
	private ArrayList<String> resumeStr;
	private View childView;

	private PopupWindow pop;

	public ActorResumePop(Activity context, ArrayList<String> resume,
			View childView) {
		this.context = context;
		this.resumeStr = resume;
		this.childView = childView;
	}

	@Override
	public void showPop() {
		dismissPop();
		View connvert = LayoutInflater.from(context).inflate(
				R.layout.pop_actor_resume, null);
		int[] arrayOfInt = new int[2];
		if (childView != null) {
			childView.getLocationInWindow(arrayOfInt);
			float pictureWidth = 450f;
			float pictureHeight = 360f;
			// 当条目被选中弹出popwindow
			pop = new PopupWindow(connvert, (int) pictureWidth,
					(int) (pictureHeight + 0.5f));
			pop.setBackgroundDrawable(new BitmapDrawable());
			pop.setFocusable(true);
			pop.showAtLocation(childView, Gravity.LEFT | Gravity.TOP,
					(int) (0 - pictureWidth), arrayOfInt[1]);
			ListView resume = (ListView) connvert
					.findViewById(R.id.actor_resume_pop);
			resume.setAdapter(new ActotDetailAdapter(resumeStr, context));
		}
	}

	@Override
	public void dismissPop() {
		if (pop != null && pop.isShowing()) {
			pop.dismiss();
			pop = null;
		}
	}

	@Override
	public boolean getPopState() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void setPopState(boolean b) {
		// TODO Auto-generated method stub

	}

}
